<template>
  <view class="my-order">
    <order-item v-for="order in orderList" :key="order.id" :order="order" />
    <empty-tip v-if="!orderList || orderList.length == 0" />
  </view>
</template>
<script lang="ts">
import "./index.less";
import OrderItem from "./components/order-item/index.vue";
import { getOrderList } from "../../../../services/order-service";
import EmptyTip from "../../../../common-components/empty-tip/index.vue"
export default {
  components: {
    orderItem: OrderItem,
    EmptyTip
  },
  data() {
    return {
      orderList: null,
      pageInfo: {
        page: 1,
        size: 100,
        total: 100,
        totalPage: 1
      }
    };
  },
  methods: {
    async getOrders() {
      const { records, total, totalPage } = await getOrderList(this.pageInfo);
      this.orderList = records;
      this.pageInfo = {
        ...this.pageInfo,
        total,
        totalPage
      };
    }
  },
  async created() {
    await this.getOrders();
  }
};
</script>
